package com.ny.demo2;

import java.util.Iterator;
import java.util.Set;

public class TestList2 {

    public void addEmp(Set<Emp2> set, Emp2 emp) {
        set.add(emp);
    }


    public void findAllEmp(Set<Emp2> set) {
        for (Emp2 emp : set) {
            System.out.println(emp);
        }
    }


    public Emp2 findEmpName(Set<Emp2> set, String name) {
        for (Emp2 emp : set) {
            if (emp.getName().equals(name)) {
                return emp;
            }
        }
        return null;
    }


    public void deleteEmp(Set<Emp2> set, String empNumber) {
        Iterator<Emp2> iterator = set.iterator();
        while (iterator.hasNext()) {
            Emp2 emp = iterator.next();
            if (emp.getNumber().equals(empNumber)) {
                iterator.remove();
                break;
            }
        }
    }

    public Emp2 findEmpNumber(Set<Emp2> set, String empNumber) {
        for (Emp2 emp : set) {
            if (emp.getNumber().equals(empNumber)) {
                return emp;
            }
        }
        return null;
    }


    public void updateEmpAge(Set<Emp2> set, Emp2 emp) {

    }
}

